package com.sinosoft.book.web;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping("/available")
    public String available() {
        System.out.println("Spring in Action");
        return "Spring in Action";
    }

    @GetMapping("/checked-out")
    public String checkedOut() {
        return "Spring Boot in Action";
    }

    @PostMapping("/add")
    public String post(@RequestBody User user) {
        System.out.println("add a model:"+user.toString());
        return user.toString();
    }

    @Data
    @ToString
    @AllArgsConstructor
    public static class User{
        private String name;
        private Integer age;

    }
}
